{extend name="public:layout" /}
{block name="title"}角色管理{/block}
{block name="head"}{/block}
{block name="body"}
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="ibox">
        <div class="ibox-title">
            <ol class="breadcrumb">
                <li><i class="fa fa-hand-o-right"></i> <a href="{:url('index',['utype'=>$Request.param.utype])}">角色管理</a></li>
                <li class="active">角色管理</li>
            </ol>
        </div>
        <div class="ibox-content">
            <div class="toolbar">
                <a class="btn btn-primary" href="{:url('add',['utype'=>$Request.param.utype])}">
                    <i class="fa fa-plus"></i>&nbsp;添加角色
                </a>
                <button class="btn btn-white" type="button"
                        onclick="updateOrder()">
                    <i class="fa fa-sort"></i>更新排序
                </button>
            </div>
            <div class="row">
                <div class="col-sm-2">
                    <ul class="nav nav-pills nav-stacked">
                        {foreach $utypeList as $utype}
                        <li {eq name="utype" value="$Request.param.utype" }class="active" {/eq}>
                        <a href="{:url('index',['utype'=>$utype])}">{$utype}</a>
                        </li>
                        {/foreach}
                    </ul>
                </div>
                <div class="col-sm-10">
                    <table class="table table-bordered" id="grid">
                        <tr>
                            <th>权限编码</th>
                            <th width="80">排序</th>
                            <th>角色名称</th>
                            <th>描述</th>
                            <th>状态</th>
                            <th width="200">操作</th>
                        </tr>
                        {volist name="groupList" id="vo"}
                        <tr>
                            <td>{$vo.group_id}</td>
                            <td>
                                <input type="text" class="form-control input-sm group-order"
                                       name="list_order[{$vo.group_id}]" value="{$vo['group_sort']}"/>
                            </td>
                            <td>{$vo.title}</td>
                            <td>{$vo.description}</td>
                            <td>{$vo.status_text}</td>
                            <td>
                                <a href="{:url('edit',['group_id'=>$vo['group_id'],'utype'=>$vo['utype']])}">编辑</a>
                                <a href="javascript:;" onclick="doAction(this);"
                                   data-msg="此操作不可逆！<br/>确认删除吗？" data-url="{:url('del')}"
                                   data-params="group_id={$vo.group_id}&utype=$vo['utype']">删除</a>
                            </td>
                        </tr>
                        {/volist}
                    </table>
                    <div class="clearfix"></div>
                </div>
            </div>
        </div>
    </div>
</div>
{/block}
{block name="script"}
<script type="text/javascript">
    //更新排序
    function updateOrder() {
        if ($(".group-order").length > 0) {
            var data = $(".group-order").serialize();
            var url = "{:url('updateOrder',['utype'=>$Request.param.utype])}";
            getAjax(url, data, function (data) {
                rePage();
            });
        }
    }
</script>
{/block}